<title><?=$v['title']?></title>
<link rel="stylesheet" type="text/css" href="css/default.css"/>
<link rel="stylesheet" type="text/css" href="css/page.css"/>
<script src="js/ui/PopWindow.js" type="text/javascript"></script>
<script src="js/Calendar.js" type="text/javascript"></script>

<style>
.refundsead{ margin:10px 0; padding:20px; color:#000; border:1px solid #ccc;}
.refundsead span{ margin-right:20px;}
.refundsead .time{ width:100px; border:1px solid #7F9DB9; height:18px; background:url("images/rili.png") no-repeat right center #FFFFFF;}
.refundsead .inptxt{ height:18px; line-height:18px; border:1px solid #7F9DB9; margin-right:30px;}
.refundsead .inpsub{cursor:pointer; background:url(../images/search.png) no-repeat left top;border:none;width:85px;height:30px;}
.refundsead .inpsub:hover{ background-position:left bottom;}
.refund-tab { width:100%; line-height:18px;}
.refund-tab th{ background:#F3F3F3; border:1px solid #DEDEE0; height:30px; text-align:center;}
.refund-tab td{ border:1px solid #D4E7FF; text-align:center; padding:5px 0;}
.refund-tab td.txtlf{ text-align:left; padding-left:15px;}
.refund-tab tbody .whiat td{ height:0px; border:0;}
.refund-tab tbody .wodtab td{ background:#E8F2FF; border:1px solid #D4E7FF; height:24px; text-align:left; padding:0 15px;}
.refund-tab tbody .wodtab td span{ margin-right:50px;}
.refund-tab tbody .wodtab td span.wid200{ width:200px; margin-right:0; display:inline-block;}
#FenID{margin:10px 0}
#FormLeft{float:left}
#FormRight{float:right;margin-top:10px;}
.refundsead div{height: 50px}

#PopWindow{ padding:20px; border:4px solid #bbb}
#PopWindow textarea{width:200px;}
#PopWindow .btn{ width:100px; height:25px; font-size:12px; cursor:pointer}

</style>

<div class="r_content">
	<h3 class="mc_title">
        <span class="mctit_1"><span class="mctit_2">提现申请列表</span></span>
    </h3>
    
	<form class="refundsead">
    <div>
        <div id='FormLeft'>
            <input type="hidden" id="act" name="act" />
            <span>
                <label>查询时间：</label>
                <select name="time">
                    <option value="apply_time">申请时间</option>
                    <option value="wd_time">处理时间</option>
                </select>
                <input type="text" class="time" onmouseup="SelectDate(this,'yyyy-MM-dd',0,0)" name="btime" value="<?=$_REQUEST['btime']?>"/>
                <label>至</label>
                <input type="text" class="time" onmouseup="SelectDate(this,'yyyy-MM-dd',0,0)" name="etime" value="<?=$_REQUEST['etime']?>"/>
            </span>
            <div id='FenID'>
                <label>分销商名称：</label>
                <input type="text" class="inptxt" name="dname" value="<?=$dname?>"/>
                <label>分销商ID：</label>
                <input type="text" class="inptxt" name="mid" value="<?=$mid?>"/>
            </div>
        </div>
        <div id='FormRight'>
            <input type="submit" class="inpsub" value=""/>
            <a href="javascript:void(0);" id="excel">导出</a>
        </div>
        </div>
	</form>
	<table class="refund-tab">
		<thead>
			<th>银行名称/收款账号(户名)</th>
			<th>金额(元)</th>
			<th>手续费</th>
			<th>转账金额</th>
			
			<th>处理人员</th>
			<th>备注</th>
			<th>处理进度</th>
			<th>操作</th>
		</thead>
		<?php foreach($r as $row):?>
        <?php 
        // $fee = $row['wd_money']<=40000 ? 2.00 : $row['tfee']/100;
        $fee = $row['tfee'];        
        ?>
		<tbody>
        	<tr class="whiat"><td colspan="8"></td></tr>
            <tr class="wodtab">
            	<td colspan="8"><span class="wid350">分销商名称：<?=$row['dname']?></span><span class="wid350">分销商ID：<?=$row['fid']?></span><span>申请时间：<?=$row['apply_time']?></span><!--<span>完成时间：<?=$row['wd_time']?></span>--></td>
            </tr>
            <tr class="user">
                <td class="txtlf"><?=$row['bank_name']?></br><?=$row['bank_accuont']." ".$row['wd_name']?></td>
                <td><?=$row['wd_money']/100?></td>
                <td><?=$fee?></td>
                <td><?=$row['wd_money']/100-$fee?></td>
                <td><?=$row['wd_operator']?$row['wd_operator']:"管理员"?></td>
				<td><a title="<?=$row['memo']?>"><?=mbsubstr($row['memo'],10,"...")?></a></td>
                <td><?=$wd_statusT[$row['wd_status']]?></td>
                <td>
                    <a href="call/handle.php?from=refund&act=suc&id=<?=$row['id']?>"  applyid="<?=$row['id']?>" class="handleSuc">转账成功</a> 
                    |
                    <a class="denybtn" applyid="<?=$row['id']?>" href="call/handle.php?from=refund&act=fail&id=<?=$row['id']?>">退回</a></td>
            </tr>
        </tbody>
		<?php endforeach;?>
	</table>
	<div class="bot"><?if($total)page($total,$currentPage,$pageSize);?></div>
</div>

<div id="pop_tpl" style="display:none">
	<form action="call/handle.php">
		<input type="hidden" name="act" value="fail"/>
		<input type="hidden" name="from" value="refund"/>
		<input type="hidden" name="id" value="" id="applyid"/>
		<h3>请填写退回申请原因：</h3>
		<textarea name="memo"></textarea></br>
		<p>（100字以内）</p>
		<input type="submit" value="提 交" class="btn submit"/>
		<input type="button" value="取 消" class="btn" onclick="popBox.close()"/>
	</form>
</div>

<div id="pop_refund" style="display:none">
	<form action="call/handle.php">
		<input type="hidden" name="act" value="suc"/>
		<input type="hidden" name="from" value="refund"/>
		<input type="hidden" name="id" value="" id="applyid_refund"/>
		<h3>请填写支付宝交易号或银行业务参考号：</h3>
		<textarea name="trade_no"></textarea></br>
		<p>&nbsp;</p>
		<input type="submit" value="提 交" class="btn submit"/>
		<input type="button" value="取 消" class="btn" onclick="popBox.close()"/>
	</form>
</div>

<script>
var popBox=new PopWindow();

$("a.denybtn").click(function(){
	var applyid=$(this).attr("applyid");
	$("#applyid").val(applyid);
	$("#pop_tpl #id").val($(this).attr("applyid"));
	popBox.open($("#pop_tpl").html())
	$("#PopWindow .submit").click(function(){
		$.ajax({
			"url":$("#PopWindow form").attr("action"),
			"dataType":"json",
			"data":$("#PopWindow form").serialize(),
			"success":function(data){
				if(data.outcome==1){
					alert("操作成功");
				}else{
					alert("操作失败:"+data.msg);
				}
				window.location=window.location.href;
			}
		});
		return false;
	});
	return false;
});


$(".handleSuc").click(function(){
    var applyid=$(this).attr("applyid");
	$("#applyid_refund").val(applyid);
	//$("#pop_refund #id").val($(this).attr("applyid"));
	popBox.open($("#pop_refund").html())
	$("#PopWindow .submit").click(function(){
        $.ajax({
            "url":$("#PopWindow form").attr("action"),
            "dataType":"json",
            "data":$("#PopWindow form").serialize(),
            "success":function(data){
                if(data.outcome==1){
                    alert("操作成功");
                }else{
                    alert("操作失败:"+data.msg);
                }
                window.location=window.location.href;
            }
        });
        return false;
    });
	return false;
});
$(".handleFail").click(function(){
	if(confirm("确定转账成功！")){
		$.ajax({
			"url":$(this).attr("href"),
			"dataType":"json",
			"success":function(data){
				if(data.outcome==1){
					alert("操作成功");
				}else{
					alert("操作失败:"+data.msg);
				}
				window.location=window.location.href;
			}
		})
	}
	return false;
});
$("#excel").click(function(){
	$("#act").val("Export");
	$("form.refundsead").submit();
	$("#act").val("");
});
</script>